SIGNATURE = b'ZI'

def _load_bytearray(path, remove_type=False) -> bytearray:
    with open(path, 'rb') as f:
        file = f.read()
        f.close()
        if remove_type:
            file = file.split(b'\n', 1)[1]
        file = bytearray(file)
        return file

def get_format(path) -> bytes:
    file = _load_bytearray(path)

    signature = bytes(chr(file[0]), 'utf-8') + bytes(chr(file[1]), 'utf-8')
    if signature != SIGNATURE:
        raise ValueError("Not a Strange I/O document")

    # 0x5A 0x49

    _type = ''
    for i in file:
        if i == 0x0A:
            break
        else:
            _type += chr(i)
    return bytes(_type.split(SIGNATURE.decode())[1], 'utf-8')

# Zany;Input
